package com.hassean.we.admin.controller;
import java.util.Map;


import com.hassean.we.common.constant.CommonConstant;
import com.hassean.we.common.util.Query;
import com.hassean.we.common.util.R;
import com.hassean.we.model.entity.IpphoneArea;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.hassean.we.admin.service.IpphoneAreaService;
import com.hassean.we.common.web.BaseController;

/**
 * <p>
 * 地区信息表(省市区县/邮政编码/区号) 前端控制器
 * </p>
 *
 * @author yajun
 * @since 2019-07-01
 */
@RestController
@RequestMapping("/ipphoneArea")
public class IpphoneAreaController extends BaseController {
    @Autowired private IpphoneAreaService ipphoneAreaService;

    /**
    * 通过ID查询
    *
    * @param id ID
    * @return IpphoneArea
    */
    @GetMapping("/{id}")
    public R<IpphoneArea> get(@PathVariable Integer id) {
        return new R<>(ipphoneAreaService.selectById(id));
    }


    /**
    * 分页查询信息
    *
    * @param params 分页对象
    * @return 分页对象
    */
    @RequestMapping("/page")
    public Page page(@RequestParam Map<String, Object> params) {
        params.put(CommonConstant.DEL_FLAG, CommonConstant.STATUS_NORMAL);
        return ipphoneAreaService.selectPage(new Query<>(params), new EntityWrapper<>());
    }

    /**
     * 添加
     * @param  ipphoneArea  实体
     * @return success/false
     */
    @PostMapping
    public R<Boolean> add(@RequestBody IpphoneArea ipphoneArea) {
        return new R<>(ipphoneAreaService.insert(ipphoneArea));
    }

}
